function(GroupDirectories inProjectFilterName inRootPath inCurrentFilesPath inOutAllItemsInDirectory)
    file(GLOB itemsInCurrentFolder LIST_DIRECTORIES true "${inCurrentFilesPath}/*")
    set(valid_src_files_in_current_folder "")
    set(all_files "")
    set(valid_extensions "\\.(rc|cpp|c|h)$")
    foreach(item ${itemsInCurrentFolder})
        string(REPLACE "${inCurrentFilesPath}/" "" relativePath "${item}")
        if(item MATCHES ${valid_extensions})
            list(APPEND valid_src_files_in_current_folder "${inCurrentFilesPath}/${relativePath}")
        elseif(IS_DIRECTORY ${item})
            GroupDirectories("${inProjectFilterName}/${relativePath}" ${inRootPath} ${item} subFolderFiles)
            list(APPEND all_files ${subFolderFiles})
        endif()
    endforeach()
    list(APPEND all_files ${valid_src_files_in_current_folder})
    source_group("${inProjectFilterName}" FILES ${valid_src_files_in_current_folder})
    set(${inOutAllItemsInDirectory} ${all_files} PARENT_SCOPE)
endfunction()
